<?php 
function using ($className)
{

    if (class_exists($className)) { 
 #       echo "<!-- {$className} is already loaded. -->\n";
        return;
    }
    
    $classPath = str_replace ('_', '/', $className) . '.php';
//    echo "<!-- Including {$classPath} -->\n";
    $classPath = realpath ($classPath);
    #echo "&lt;!-- Including {$classPath} --&gt;<br/>";
	if (file_exists($classPath))
	{
        require ($classPath);
		return;
	}
	echo "File {$classPath} was not found";
}

function redirect ($url=NULL)
{
    $href   = $url ? $url : $_SERVER['SCRIPT_URL'];
    $script = '<'.'script language="javascript">' . 
              'function _$() { location.href="%s"; }' . 
              'function go() {' . 
              '    document.write ("Redirecting to %s...");' . 
              '    setTimeout (_$, 1000);' . 
              '}' . 
              'go ();' . 
              '</'.'script>' . 
              '';
    echo sprintf($script, $href, $href);
    exit;
   # header (sprintf('Location: %s', $url ? $url : $_SERVER['SCRIPT_NAME']));
}

function enablecli ()
{
    $filename = "./messages.xml";
    if (file_exists($filename)) 
    {
		$xml       = simplexml_load_file($filename);
		$result    = $xml->xpath("//message"); //echo sizeof ($result);
		for ($x=0;$x<sizeof($result);$x++)
		{
		    $className = $result[$x]->class;
		    $className = "{$className}"; //echo "{$className}\n";
		    using ($className);
		   
		}
		return;
    } 
    echo "Could not load message data";
    
} 



